home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- #
- # Perl configuration script for WinLIB
- # by Ken Hollis
- #
- # Version 1.0.0
-
- $> && die "\nYou must be root or superuser to build the WinLIB library.\n\n";
- $| = 1;
-
- sub ask {
- $question = "";
- $default = "";
- $prompt = "";
-
- $question = $_[0];
- $default = $_[1];
- $prompt = $_[2];
-
- print "${question} ${prompt} ";
-
- $answer = <stdin>;
- chop($answer);
-
- $answer =~ tr/a-z/A-Z/;
-
- if (($answer eq "") || ($answer eq $default)) {
- return 1;
- } else {
- return 0;
- }
- }
-
- sub find {
- open(FI, "which $_[0]|");
- while(<FI>) {
- chop;
- if (/no/) {
- return 0;
- } else {
- return $_;
- }
- }
- close(FI);
- }
-
- sub do_stuff {
- system("clear");
- print <<"EOT";
- * Welcome to WinLIB 0.0.3 installation script.
- * Checking some stuff...
-
- EOT
- $system = `uname`;
- $os_ver = `uname -r`;
-
- chop($system);
- chop($os_ver);
-
- if ($system eq "Linux") {
- print "* Linux version $os_ver.\n";
- } else {
- print <<"EOT";
- Sorry, you're not running Linux. This library requires Linux in order to
- compile correctly. Ports may be made to your operating system, but
- currently, the library only supports Linux. Sorry!
- EOT
- exit;
- }
-
- print "* One moment...";
- `cd config ; make -s`;
- print "\r \r";
-
- open(VER, "cd config ; check|");
- while(<VER>) {
- chop;
- ($gpmver,$ncursesver) = split(/:/);
- }
- close(VER);
-
- print "* GPM Version $gpmver installed.\n";
- print "* NCURSES Version $ncursesver installed.\n";
- print "\n";
-
- $elf = &ask("Create ELF shared library?", "Y", "[Y/n]");
- $aout = &ask("Create A.OUT static library?", "Y", "[Y/n]");
- $dg = &ask("Enable -g option on libraries? (Makes larger libs)?", "N", "[y/N]");
- $dg = ($dg == 1) ? "" : "-g ";
-
- die "\nYou need to create at least one library!\n\n" if (($elf == 0) && ($aout == 0));
-
- print "\n";
-
- $debug = &ask("Enable debugging?", "Y", "[Y/n]");
- $show_coord = &ask("Enable mouse coordinate info?", "Y", "[Y/n]");
- $color = &ask("Enable color support?", "Y", "[Y/n]");
- $sound = &ask("Enable sound support?", "Y", "[Y/n]");
-
- if ($sound == 1) {
- $aud = &ask("Enable use of \"/dev/audio\" device?", "Y", "[Y/n]");
- $audio = ($aud == 1) ? "#define\tUSE_DEV_AUDIO" : "#undef\tUSE_DEV_AUDIO";
- $soundprog = &find("play");
- if ($soundprog ne "") {
- $sf = &ask("Found \"play\" in \"$soundprog\" for .WAV files. Use it?", "Y", "[Y/n]");
- if ($sf == 1) {
- $sfp = ($sf == 1) ? "#define\tWAVFILE\t\t\"$soundprog\"" : "#undef\tWAVFILE";
- }
- } else {
- print "\n* No .WAV file player found. .WAV file support disabled.\n";
- }
- }
-
- print "\nWhat's the IP address of your sound server? ";
- $ipaddr = <stdin>;
- chop($ipaddr);
-
- $debug = ($debug == 1) ? "#define\tDEBUG" : "#undef\tDEBUG";
- $coord = ($show_coord == 1) ? "#define\tMOUSE_COORD" : "#undef\tMOUSE_COORD";
- $color = ($color == 1) ? "#define\tCOLOR_SUPPORT" : "#undef\tCOLOR_SUPPORT";
- $sound = ($sound == 1) ? "#define\tSOUND_SUPPORT" : "#undef\tSOUND_SUPPORT";
- $soundip = "#define\tSOUND_ADDRESS\t\"$ipaddr\"";
-
- open(OUTF, ">Makefile.defs") || die "Makefile.defs: $!\n";
- print OUTF "# This file is automatically generated by the Configuration\n";
- print OUTF "# program. Do not change this file!\n\n";
- print OUTF "DONE_CONFIG= 1\n";
- print OUTF "AOUT_LIB= $aout\n";
- print OUTF "ELF_LIB= $elf\n";
- close(OUTF);
-
- open(INF, "config.h.in") || die "(Open) config.h.in: $!\n";
- open(OUTF, ">config.h") || die "(Write) config.h: $!\n";
- while(<INF>) {
- s/\$0/$debug/;
- s/\$1/$coord/;
- s/\$2/$color/;
- s/\$3/$sound/;
- s/\$4/$sfp/;
- s/\$5/$audio/;
- s/\$6/$soundip/;
- print OUTF $_;
- }
- close(OUTF);
- close(INF);
-
- open(INF, "Makefile.in") || die "Makefile.in: $!\n";
- open(OUTF, ">Makefile") || die "Makefile: $!\n";
- while(<INF>) {
- s/\$0/$dg/;
- print OUTF $_;
- }
- close(OUTF);
- close(INF);
-
- print <<"EOT";
-
- * Great! We're done.
- * You should now be able to type \"make\" and everything will take place
- according to plan.
- * If you are skeptical, please edit \"config.h\" before typing \"make\".
-
- EOT
- }
-
- &do_stuff;
-